package Day16;

import java.util.Scanner;

public class Text7 {
    public static void main(String[] args) {
      /*  int[] arr1 = {1,2,3};
        Scanner sc = new Scanner(System.in);
        do {
            int[] arr2= new int[arr1.length + 1];
            for(int i = 0; i <= arr1.length -1; i++){
                arr2[i] = arr1[i];
            }
            System.out.println("请输入你要添加的元素");
            int addNum = sc.nextInt();
            arr2[arr2.length - 1] = addNum;
            arr1 = arr2;
            System.out.println("======数组扩容之后的情况======");
           //输出arr1，看看效果
            for (int i = 0; i < arr1.length; i++) {
                System.out.print(arr1[i] + "\t");
            }
            System.out.println("是否还要继续添加 y/n");
            char key = sc.next().charAt(0);
            if(key == 'n'){
                break;
            }
        } while (true);*/

       /* int[] arr1 = {1,2,3};
        int[] arr2 = new int[arr1.length + 1];
        Scanner sc = new Scanner(System.in);
        do{
            for(int i = 0; i <= arr1.length - 1; i++){
                arr2[i] = arr1[i];
            }
            System.out.println("请输入要添加的元素");
            int addNum = sc.nextInt();
            //把元素赋给arr2
            arr2[arr2.length - 1] = addNum;
            arr1 = arr2;
            System.out.println("扩容之后的情况是");
            for (int i = 0; i < arr1.length; i++) {
                System.out.print(arr1[i] + "\t");
            }
            System.out.println("是否要继续添加元素 y/n");
            char key = sc.next().charAt(0);
            if(key == 'n'){
                break;
            }
        }while(true);
*/
       /* Scanner sc = new Scanner(System.in);
      int[] arr = {1,2,3};
      do{
          int[] arr2 = new int[arr.length + 1];
          for(int i = 0; i < arr.length; i++){
              arr2[i] = arr[i];
          }
          System.out.println("\n请输入要添加的元素");
          int addNum = sc.nextInt();
          arr2[arr2.length -1] = addNum;
          arr = arr2;
          System.out.println("是否继续添加 y / n");
          char key = sc.next().charAt(0);
          for (int k = 0; k < arr2.length; k++) {
              System.out.print(arr2[k] + "\t");
          }
          if(key == 'n'){
              break;
          }
      }while(true);
*/



        Scanner sc = new Scanner(System.in);
        int[] arr1 = {12,3,45};
       do{
           int[] arr2 = new int[arr1.length + 1];
           for(int i = 0; i < arr1.length; i++){
               arr2[i] = arr1[i];
           }
           System.out.println("请输入要添加的元素");
           int addNum = sc.nextInt();
           arr2[arr2.length -1] = addNum;
           arr1 = arr2;
           for (int k = 0; k < arr2.length; k++) {
               System.out.print(arr2[k] + "\t");
           }

       }while(true);


   }
}
